package com.yidiandao.business.ui.widget.listview.displaylistitem;

import android.content.Context;

import com.yidiandao.business.data.bean.FavourableInfo;
import com.yidiandao.business.data.bean.Goods;
import com.yidiandao.business.ui.widget.listview.DisplayListItem;
import com.yidiandao.business.ui.widget.listview.viewholder.ShoppingCartGoodsReduceHolder;

/** 购物车 单商品 满减 活动 ListItem */
public class ShoppingCartGoodsReduceListItem
        extends DisplayListItem<ShoppingCartGoodsReduceHolder, FavourableInfo> {

    public ShoppingCartGoodsReduceListItem(FavourableInfo s) {
        super(s);
    }

    @Override
    public void onShow(Context context, ShoppingCartGoodsReduceHolder holder) {

        // 设置 满减活动 的标题
        holder.setTitle(data.getTitle());

        // 当前满减活动属于商品活动
        Goods belongGoods = data.getBelongGoods();

        // 判断满减活动的条件是否已经满足
        if (data.getCanChoose() == FavourableInfo.CAN_CHOOSE && belongGoods.isSelected()) {
            // 满足、且当前商品是选中的
            // 显示 已减免 xxx 元 (选中的时候的内容)
            // todo 记录减免的金额
            holder.setContent(data.getSelectedContent());
        } else {
            // 设置为 活动的具体内容
            holder.setContent(data.getContent());
        }
    }

    @Override
    public String getDisplayItemTag() {
        return ShoppingCartGoodsReduceListItem.class.getSimpleName();
    }

    @Override
    public Class<ShoppingCartGoodsReduceHolder> getViewHolderClazz() {
        return ShoppingCartGoodsReduceHolder.class;
    }
}
